#ifndef DI8INPUT_H
#define DI8INPUT_H

#include <iInputDevice.h>

#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>

namespace Input_DI {
	using imInput::InputDevType;
	
	extern "C" __declspec(dllexport) HRESULT CreateInputDevice(HINSTANCE hDLL, imInput::iInputDevice **pDevice, imInput::InputDevType DevType);
	extern "C" __declspec(dllexport) HRESULT ReleaseInputDevice(imInput::iInputDevice **pDevice);

	extern LPDIRECTINPUT8 g_DI;
	extern bool g_Initialized;

	class DIKBInputDevice : public imInput::iInputDevice {
	protected:
		HWND hWndMain;
		HINSTANCE hInstance;
		LPDIRECTINPUTDEVICE8 DIDev;
		
		char BufferNow[256];
		char BufferLast[256];
	public:
		DIKBInputDevice(void) {memset(&BufferNow, 0, sizeof(BufferNow));
							 memset(&BufferLast, 0, sizeof(BufferLast));};
		~DIKBInputDevice(void) {Release();};

		HRESULT Init(HINSTANCE, HWND);
		void Release(void);
		void Update(void);
		bool KeyDown(int);
		bool KeyUp(int);
		bool KeyPress(int);
		bool KeyRelease(int);
	};

	class DIMoInputDevice : public imInput::iInputDevice {
	protected:
		HWND hWndMain;
		HINSTANCE hInstance;
		LPDIRECTINPUTDEVICE8 DIDev;

		DIMOUSESTATE State;
	public:
		DIMoInputDevice(void) {memset(&State, 0, sizeof(State));};
		~DIMoInputDevice(void) {Release();};

		HRESULT Init(HINSTANCE, HWND);
		void Release(void);
		void Update(void);
		bool KeyUp(int);
		bool KeyDown(int);
		long AxisPos(int);
	};
}

#endif